package com.ngovanhau.justsort.item.config;

import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;

import com.ngovanhau.justsort.model.LevelSetting;

import android.app.Activity;
import android.util.Log;

public class MyConfig {
	public static int SCREENWIDTH;
	public static int SCREENHEIGHT;
	public static ScreenOrientation ScreenOrientation_Default = ScreenOrientation.PORTRAIT;

	public static int HEIGHT_TOP = 100, HEIGHT_BOTTOM = 84;
	public static int PADDING_LEFT = 10, PADDING_RIGHT = 10;
	public static float RACE_HEIGHT = 1f, RACE_WIDTH = 1f;

	public static float WIDTH_NUMBER = 160, HEIGHT_NUMBER = 160;
	public static float WIDTH_BG = 480, HEIGHT_BG = 486;
	public static int X_START = 10, X_END = -1, Y_START = 10, Y_END = -1;

	public final static int X_START_ = 10, X_END_ = -1, Y_START_ = 10,
			Y_END_ = -1;

	public final static float HEIGHT_ = 590;
	public static float  HEIGHT = 590;

	public static float getCenterX() {
		return SCREENWIDTH / 2;
	}
	
	public static float getCenterY() {
		return SCREENHEIGHT / 2;
	}

	public static void getDisplayScreen(Activity activity) {
		SCREENWIDTH = activity.getWindowManager().getDefaultDisplay()
				.getWidth();
		SCREENHEIGHT = activity.getWindowManager().getDefaultDisplay()
				.getHeight();

		RACE_WIDTH = (float) SCREENWIDTH / (float) 480;
		RACE_HEIGHT = (float) SCREENHEIGHT / (float) 800;

		reSizeNumber();
	}

	public static float getHeightBottom() {
		return HEIGHT_BOTTOM * RACE_HEIGHT;
	}

	public static float getHeightTop() {
		return HEIGHT_TOP * RACE_HEIGHT;
	}

	public static float getPaddingLeft() {
		return PADDING_LEFT * RACE_WIDTH;
	}

	public static float getRaceHeight() {
		return RACE_HEIGHT;
	}

	public static float getRaceWidth() {
		return RACE_WIDTH;
	}

	public static int getTotalPadding() {
		return (int) (PADDING_LEFT * RACE_WIDTH + PADDING_RIGHT * PADDING_RIGHT);
	}

	public static void reSizeNumber() {
		X_START = (int) (X_START_ * RACE_WIDTH);
		HEIGHT = HEIGHT_ * RACE_HEIGHT;

		WIDTH_BG = SCREENWIDTH;

		WIDTH_NUMBER = (SCREENWIDTH + 5 - X_START * 2)
				/ LevelSetting.columnLevel;
		HEIGHT_NUMBER = WIDTH_NUMBER;
		HEIGHT_BG = HEIGHT_NUMBER* LevelSetting.rowLevel;
		if (HEIGHT_BG > HEIGHT) {
			HEIGHT_BG = HEIGHT;
			HEIGHT_NUMBER = HEIGHT_BG / LevelSetting.rowLevel;
			HEIGHT_BG = HEIGHT_NUMBER * LevelSetting.rowLevel;
			Y_START = (int) (MyConfig.SCREENHEIGHT / 2 - HEIGHT_BG / 2 - 5 * RACE_HEIGHT);
			Log.d("thuy yoyo", WIDTH_NUMBER + "============111=============== "
					+ HEIGHT_BG);

		} else if (HEIGHT_BG < WIDTH_BG) {
			HEIGHT_NUMBER = (int) (HEIGHT_NUMBER * 1.2);
			HEIGHT_BG = HEIGHT_NUMBER * LevelSetting.rowLevel;
			Y_START = (int) (MyConfig.SCREENHEIGHT / 2 - HEIGHT_BG / 2 - 5 * RACE_HEIGHT);
			Log.d("thuy yoyo", WIDTH_NUMBER + "============2222=============== "
					+ HEIGHT_BG);
		} else {
			Y_START = (int) (MyConfig.SCREENHEIGHT / 2 - HEIGHT_BG / 2 - 5 * RACE_HEIGHT);
			Log.d("thuy yoyo", WIDTH_NUMBER + "============333=============== "
					+ HEIGHT_BG);

		}
	}
}
